package com.xp.basic.heima.nio.netty.simpledemo.chat.message;

import lombok.Data;

import java.io.Serializable;

/***
 * 顶级消息对象
 */
@Data
public abstract class Message implements Serializable {

    /**
     * 魔数
     */
    private int  magicNum;

    /**
     * 消息版本号
     */
    private int  version;

    /**
     * 序列化方式 0 Java 1 json、 2 protobuf、 3 hessian
     */
    private int  serializeType;

    /**
     * 指令类型
     */
    private int  messageType;

    /**
     * 消息序号
     */
    private int  squenceId;


    /**
     * 消息内容长度
     */
    private int  messageLength;

    /**
     * 消息正文
     */
    private Object content;

    /**
     * 获取消息类型
     * @return
     */
    public abstract int  getMessageType();

    public static final int LoginRequestMessage = 0;
    public static final int LoginResponseMessage = 1;
    public static final int ChatRequestMessage = 2;
    public static final int ChatResponseMessage = 3;
    public static final int GroupCreateRequestMessage = 4;
    public static final int GroupCreateResponseMessage = 5;
    public static final int GroupJoinRequestMessage = 6;
    public static final int GroupJoinResponseMessage = 7;
    public static final int GroupQuitRequestMessage = 8;
    public static final int GroupQuitResponseMessage = 9;
    public static final int GroupChatRequestMessage = 10;
    public static final int GroupChatResponseMessage = 11;
    public static final int GroupMembersRequestMessage = 12;
    public static final int GroupMembersResponseMessage = 13;

    public static final int PingMessage = 14;
    public static final int PongMessage = 15;

    public static final int RPC_MESSAGE_TYPE_REQUEST = 101;
    public static final int  RPC_MESSAGE_TYPE_RESPONSE = 102;


}
